#ifndef _MY_EVENT_HANDLER_HPP
#define _MY_EVENT_HANDLER_HPP

#include <CtrlLib/CtrlLib.h>
#include "MyEventQueue.hpp"
#include "Events.hpp"

using namespace Upp;

/**
 * @brief Event handler Base class, all event handlers should inherit from this class
 *        Register OnEvent(MyEvent& e) to handle events
 * 
 */
class MyEventHandler
{
public:
    // use std::initializer_list to register event id
    typedef MyEventHandler CLASSNAME;
    MyEventHandler(std::initializer_list<int> eventIds)
    {
        for (auto id : eventIds)
        {
            MyRegisterEvent(id, THISBACK(OnEvent));
        }
    }

    virtual ~MyEventHandler()
    {
    }

    /**
     * @brief Event handler function
     * 
     * @param e 
     */
    virtual void OnEvent(const MyEvent& e) = 0; 
};

class LineEventHandler : public MyEventHandler
{
public:
    LineEventHandler() : MyEventHandler({EVENT_SERIAL_DATA_RECV})
    {
    }
    ~LineEventHandler()
    {
    }
    virtual void OnEvent(const MyEvent& e) override
    {
    }
};

#endif